package com.xinnet.mms.allot.service.impl;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xinnet.core.utils.page.PageView;
import com.xinnet.mms.allot.dao.CustomMixDao;
import com.xinnet.mms.allot.service.CustomMixService;
import com.xinnet.mms.entity.CustomMix;
import com.xinnet.mms.entity.CustomMixAudit;
import com.xinnet.mms.entity.CustomMixDept;

@Service("customMixService")
public class CustomMixServiceImpl implements CustomMixService {

	@Autowired
	CustomMixDao customMixDao;
	
	//分页查询所有已分配的客户
	@Override
	public PageView<CustomMix> queryAllCustomer(PageView<CustomMix> pageView) throws SQLException {
		pageView=customMixDao.queryAllCustomer(pageView);
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	//查询调配弹窗的信息
	@Override
	public CustomMixDept showInMixDiv(String cusId) throws SQLException {
		return customMixDao.showInMixDiv(cusId);
	}

	//添加客户调配信息进入客户调配审核
	@Override
	public void addCustomMixAudit(CustomMixAudit customMixAudit) throws SQLException {
		customMixDao.addCustomMixAudit(customMixAudit);
	}

	//通过查询条件过滤客户调配页面客户信息
	@Override
	public PageView<CustomMix> queryCustomMixByTrem(PageView<CustomMix> pageView,CustomMix customMix) throws SQLException {
		pageView=customMixDao.queryCustomMixByTrem(pageView,customMix);
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	/**
	 * 修正审核中但未显示的错误记录
	 */
	@Override
	public void updateCustomflagByEmpno(String empno) throws SQLException {
		customMixDao.updateCustomflagByEmpno(empno);
	}

	/**
	 * 根据id获取调配记录
	 */
	@Override
	public CustomMixAudit getCustomMixAuditById(String id) throws SQLException {
		return customMixDao.getCustomMixAuditById(id);
	}

	@Override
	public PageView<CustomMixAudit> queryMixCustomersByCondition(
			PageView<CustomMixAudit> pageView,CustomMixAudit customMixAudit) {
		return customMixDao.queryMixCustomersByCondition(pageView,customMixAudit);
	}
	
	public Integer queryMixCustomerCount(CustomMixAudit customMixAudit){
		return customMixDao.queryMixCustomerCount(customMixAudit);
	}

	@Override
	public void updateCustomMixAudit(CustomMixAudit customMixAudit) {
		customMixDao.updateCustomMixAudit(customMixAudit);
	}

}
